package alogrithm.tree;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 树状数组
 * @author Administrator
 *
 */
public class ArrayTree {
	
	public int normalSum(Integer a[]){
		int sum=0;
		for(int i=0;i<a.length;i++){
			sum+=a[i];
		}
		return sum;
	}
	
	int lot(int n){
		return n&(-n);
	}
	
	int sum(int n,int a[]){
		int sum=0;
		while(n!=0){
			sum+=a[n];
			n=n-lot(n);
			System.out.printf("n is %d\n",n);
		}
		return sum;
	}
	
	public static void main(String[] args) {
		ArrayTree at=new ArrayTree();
		int a[]=new int[]{1,3,4,3,9,8};
		int s=at.sum(a.length-1, a);
		System.out.println(s);
		System.out.println(Math.log(7));
	}
}
